<?php

namespace App\Repositories;

use App\Models\ItemManager;
use InfyOm\Generator\Common\BaseRepository as iBaseRepository;

class ItemManagerRepository extends iBaseRepository
{
    /**
     * @var array
     */
    protected $fieldSearchable = [
        'item_id',
        'wechat_user_id',
        'status'
    ];

    /**
     * Configure the Model
     **/
    public function model()
    {
        return ItemManager::class;
    }

    public function getManagerByWechatUserId($wechatUserId)
    {
        return $this->model->where('wechat_user_id', $wechatUserId)->first();
    }

    public function getManagerByItemIdAndWechatUserId($itemId, $wechatUserId)
    {
        return $this->model->where('item_id', $itemId)->where('wechat_user_id', $wechatUserId)->first();
    }
}
